import util.JDBCUtils;

import java.sql.*;

public class JDBCDemo {
    public static void main(String[] args) throws SQLException {
        //获得数据库对象connection
        Connection connection = JDBCUtils.getConnection();
        //获取sql执行对象statement
        Statement statement = connection.createStatement();
        //执行sql
        //4.获取执行sql的对象
        String sql = "select * from student2 where sid<10";
        //5.执行sql 查询操作
        ResultSet resultSet = statement.executeQuery(sql);
//        无返回值操作
//        statement.execute();
//        用于增删改
//        statement.executeUpdate();
        while (resultSet.next()) {
            System.out.println("sid:" + resultSet.getObject("sid") +
                    "sname:" + resultSet.getObject("sname"));
        }
        //释放连接
        JDBCUtils.release(connection, statement, resultSet);
    }
}

